import frontRequest from "@/utils/http/frontRequest.js";

// 获取图形验证码
export const imageVerifyCodeGetAPI = () => {
    return frontRequest.get('/user/getverifycode')
}

// 获取邮箱验证码
export const emailVerifyCodeGetAPI = (email) => {
    return frontRequest.get('/user/sendemailcode', {
        params: {email}
    })
}

// 登录-通过账号或者邮箱和密码
export const loginByUsernameOrEmailWithPasswordAPI = ({usernameOrEmail, password, code, token}) => {
    return frontRequest.post('/user/login', {usernameOrEmail, password, code, token})
}

// 登录-通过邮箱验证码
export const loginByEmailWithVerityCodeAPI = ({email, code}) => {
    return frontRequest.post('/user/loginbyemail', {email, code})
}

// 获取个人信息
export const userInfoGetAPI = () => {
    return frontRequest.get('/user/userinfo')
}

// 添加至愿望单
export const wishlistAddAPI = (gameId) => {
    return frontRequest.post('/user/wishlist', {
        gameId
    })
}

// 注册
export const register = ({username, nickname, password, email, code}) => {
    return frontRequest.post('/user/register', {username, nickname, password, email, code})
}

// 获取好友列表
export const friendsListGetAPI = (usernameOrNickname) => {
    return frontRequest.get('/user/friends', {
        params: {usernameOrNickname}
    })
}

// 修改密码
export const recoverPasswordAPI = ({email, code, password, rePassword}) => {
    return frontRequest.put('/user/password', {email, code, password, rePassword})
}

// 将游戏添加至仓库
export const gameAddToLibraryAPI = (gameId) => {
    return frontRequest.post('/user/game', {gameId})
}
